<template>
  <div align="right" >
    <!--0.退货  1.换货 2.仅退款-->
    <my-button type="success" v-if="this.$props.currApply.status.id===0" :click="function(){handler()}" access-action="OrderApply/manage" text="处理申请"></my-button>
    <my-button type="success" v-if="this.$props.currApply.status.id===2" :click="function(){confirmReceive()}" access-action="OrderApply/manage" text="确认收货"></my-button>
    <my-button type="success"
               v-if="this.$props.currApply.status.id===3 && this.$props.currApply.type.id===1"
               :click="function(){exchangeStartSend()}"
               access-action="OrderApply/manage"
               text="确认发货"></my-button>

    <my-button type="primary" size="mini"
               v-if="this.$props.currApply.systemStatus && this.$props.currApply.systemStatus.id>0" :click="function (){showSystemApplyLog()}"
               text="查看-平台介入处理记录" access-action="OrderApply/manage"></my-button>

    <my-button type="warning" :click="function() {
      $router.push('/OrderDetail?id='+$props.currApply.orderId)
    }" access-action="OrderApply/manage" text="订单详情"></my-button>

  </div>
</template>

<script>
import MyButton from './MyButton'
export default {
  name: 'OrderApplyActButton',
  components: {MyButton},
  props:{
    currApply:Object,
    callBack:Function
  },
  methods:{
    showSystemApplyLog:function () {
      this.bus.$emit('ShowSystemApplyLogDialogCallBus',this.$props.currApply.id,'OrderApply')
    },
    // 售后(退换货)
    apply:function () {
      var query={
        orderId:this.$props.currApply.id,
        applyId:this.$props.currApply.applyId
      }
      this.$router.push({
        name:'OrderApply',
        query:query
      })
    },
    // 开始配送
    handler: function () {
      let $this=this
      $this.bus.$emit('OrderApplyHandlerDialogCallBus',$this.$props.currApply,function () {
        if (typeof $this.$props.callBack==='function'){
          $this.$props.callBack()
        }
      })
    },
    confirmReceive:function () {
      let $this=this
      $this.$confirm('您确认要进行该操作吗, 是否继续?', '系统提示', {
        customClass: 'my-confirm-box',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        backType: 'warning'
      }).then(() => {
        $this.MyRequest($this.ApiDoNameShop+'OrderApply/receivedApply',{id:$this.$props.currApply.id},function (data) {
          if (typeof $this.$props.callBack==='function'){
            $this.$props.callBack()
          }
          $this.$forceUpdate()
        })
      }).catch(() => {

      })
    },
    exchangeStartSend(){
      let $this=this
      $this.bus.$emit('OrderApplyStartSendDialogCallBus',$this.$props.currApply,function () {
        if (typeof $this.$props.callBack==='function'){
          $this.$props.callBack()
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
